package com.sptpc.learnspring.service.impl;

import com.sptpc.learnspring.mapper.CategoryMapper;
import com.sptpc.learnspring.model.Category;
import com.sptpc.learnspring.service.ICategoryService;
import com.sptpc.learnspring.vo.CategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements ICategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> getAllCategories() {
        List<Category> list = categoryMapper.getAllCategories();
        return list;
    }

    @Override
    public Category getCategoryById(long id) {
        return categoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public CategoryVO getCategoryWithDrinks(Long id) {
        return categoryMapper.selectByPrimaryKeyWithDrinks(id);
    }
}
